import storageUtil from '@/utils/StorageUtil'

// local storage Key常量
export const PageVersionKey = 'ps_TmptTbColumn-page-version-key'
export const ConditionShowListCkedKey = 'ps_TmptTbColumn-condition-column-show-cked-list-key'
export const ColumnShowListCkedKey = 'ps_TmptTbColumn-list-column-show-cked-list-key'
export const isDropMenuKey = 'ps_TmptTbColumn-list-column-show-isdropmenu-key'
export const ColumnShowListWidthKey = 'ps_TmptTbColumn-list-column-width-key'
export const IsExpandedRowCkedKey = 'ps_TmptTbColumn-list-isexpanded-row-key'


// 查询条件 type: input/date/date-range/num-range/select/tree/
export const conditionOptions = [
  { property: 'id', label: 'ID', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Id', remoteUrl: '' },
  { property: 'columnname', label: 'columnname', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columnname', remoteUrl: '' },
  { property: 'columnnamesql', label: 'columnnamesql', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columnnamesql', remoteUrl: '' },
  { property: 'columnnamesqlsum', label: 'columnnamesqlsum', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columnnamesqlsum', remoteUrl: '' },
  { property: 'columnshowname', label: 'columnshowname', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columnshowname', remoteUrl: '' },
  { property: 'isfrozencolumn', label: 'isfrozencolumn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Isfrozencolumn', remoteUrl: '' },
  { property: 'needsum', label: 'needsum', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Needsum', remoteUrl: '' },
  { property: 'sort', label: 'sort', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sort', remoteUrl: '' },
  { property: 'ishidden', label: 'ishidden', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Ishidden', remoteUrl: '' },
  { property: 'canadd', label: 'canadd', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Canadd', remoteUrl: '' },
  { property: 'tmptTableId', label: 'tmptTableId', width: 200, show: true, type: 'input', dataResource: 0, enumName:'TmptTableId', remoteUrl: '' },
  { property: 'isquery', label: 'isquery', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Isquery', remoteUrl: '' },
  { property: 'columntype', label: 'columntype', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columntype', remoteUrl: '' },
  { property: 'issortcolumn', label: 'issortcolumn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Issortcolumn', remoteUrl: '' },
  { property: 'optionssql', label: 'optionssql', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Optionssql', remoteUrl: '' },
  { property: 'dataresource', label: 'dataresource', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Dataresource', remoteUrl: '' },
  { property: 'optionspage', label: 'optionspage', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Optionspage', remoteUrl: '' },
  { property: 'tablealiasname', label: 'tablealiasname', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablealiasname', remoteUrl: '' },
  { property: 'columnwidth', label: 'columnwidth', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Columnwidth', remoteUrl: '' },
  { property: 'createdate', label: '创建日期', width: 200, show: true, type: 'date-range', dataResource: 0, enumName:'Createdate', remoteUrl: '' },
  { property: 'deleteflag', label: '删除标志', width: 200, show: true, type: 'select', dataResource: 1, enumName:'Deleteflag', remoteUrl: '/core/enum/getData4AddBy' },
  { property: 'inputwidth4adddialog', label: 'inputwidth4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Inputwidth4adddialog', remoteUrl: '' },
  { property: 'linewidth4adddialog', label: 'linewidth4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Linewidth4adddialog', remoteUrl: '' },
  { property: 'required4adddialog', label: 'required4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Required4adddialog', remoteUrl: '' },
  { property: 'dataoptions4adddialog', label: 'dataoptions4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Dataoptions4adddialog', remoteUrl: '' },
  { property: 'style4adddialog', label: 'style4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Style4adddialog', remoteUrl: '' },
  { property: 'charttype', label: 'charttype', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Charttype', remoteUrl: '' },
  { property: 'columnDatatype', label: 'columnDatatype', width: 200, show: true, type: 'input', dataResource: 0, enumName:'ColumnDatatype', remoteUrl: '' },
  { property: 'columnIsnotnull', label: 'columnIsnotnull', width: 200, show: true, type: 'input', dataResource: 0, enumName:'ColumnIsnotnull', remoteUrl: '' },
  { property: 'queryType', label: 'queryType', width: 200, show: true, type: 'input', dataResource: 0, enumName:'QueryType', remoteUrl: '' },
  { property: 'defaultValue', label: 'defaultValue', width: 200, show: true, type: 'input', dataResource: 0, enumName:'DefaultValue', remoteUrl: '' },
  { property: 'columnTip', label: 'columnTip', width: 200, show: true, type: 'input', dataResource: 0, enumName:'ColumnTip', remoteUrl: '' },
  { property: 'dataTransfer', label: 'dataTransfer', width: 200, show: true, type: 'input', dataResource: 0, enumName:'DataTransfer', remoteUrl: '' },
  { property: 'columnlayoutStyle4adddialog', label: 'columnlayoutStyle4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'ColumnlayoutStyle4adddialog', remoteUrl: '' }
]
// 所有列对象
export const theadOptions = [
      { property: 'id', label: 'ID', width: storageUtil.getColumnWidthFromStorage('id', 150, ColumnShowListWidthKey), show: true, edit: false, sort: 'custom', fixed: false} ,
      { property: 'columnname', label: 'columnname', width: storageUtil.getColumnWidthFromStorage('columnname', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnnamesql', label: 'columnnamesql', width: storageUtil.getColumnWidthFromStorage('columnnamesql', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnnamesqlsum', label: 'columnnamesqlsum', width: storageUtil.getColumnWidthFromStorage('columnnamesqlsum', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnshowname', label: 'columnshowname', width: storageUtil.getColumnWidthFromStorage('columnshowname', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'isfrozencolumn', label: 'isfrozencolumn', width: storageUtil.getColumnWidthFromStorage('isfrozencolumn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'needsum', label: 'needsum', width: storageUtil.getColumnWidthFromStorage('needsum', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sort', label: 'sort', width: storageUtil.getColumnWidthFromStorage('sort', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'ishidden', label: 'ishidden', width: storageUtil.getColumnWidthFromStorage('ishidden', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'canadd', label: 'canadd', width: storageUtil.getColumnWidthFromStorage('canadd', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tmptTableId', label: 'tmptTableId', width: storageUtil.getColumnWidthFromStorage('tmptTableId', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'isquery', label: 'isquery', width: storageUtil.getColumnWidthFromStorage('isquery', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columntype', label: 'columntype', width: storageUtil.getColumnWidthFromStorage('columntype', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'issortcolumn', label: 'issortcolumn', width: storageUtil.getColumnWidthFromStorage('issortcolumn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'optionssql', label: 'optionssql', width: storageUtil.getColumnWidthFromStorage('optionssql', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'dataresource', label: 'dataresource', width: storageUtil.getColumnWidthFromStorage('dataresource', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'optionspage', label: 'optionspage', width: storageUtil.getColumnWidthFromStorage('optionspage', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablealiasname', label: 'tablealiasname', width: storageUtil.getColumnWidthFromStorage('tablealiasname', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnwidth', label: 'columnwidth', width: storageUtil.getColumnWidthFromStorage('columnwidth', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'createdate', label: '创建日期', width: storageUtil.getColumnWidthFromStorage('createdate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'createman', label: '创建人', width: storageUtil.getColumnWidthFromStorage('createman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      // 枚举对象， json结构，如: {'id':1, 'name':'无效'}
      { property: 'deleteflag.name', label: '删除标志', width: storageUtil.getColumnWidthFromStorage('deleteflag.name', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false, dataResource: 1, columnType: 'select', enumName:'Deleteflag', remoteUrl: '/core/enum/getData4AddBy'} ,
      { property: 'modifydate', label: '修改日期', width: storageUtil.getColumnWidthFromStorage('modifydate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'modifyman', label: '修改人', width: storageUtil.getColumnWidthFromStorage('modifyman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'inputwidth4adddialog', label: 'inputwidth4adddialog', width: storageUtil.getColumnWidthFromStorage('inputwidth4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'linewidth4adddialog', label: 'linewidth4adddialog', width: storageUtil.getColumnWidthFromStorage('linewidth4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'required4adddialog', label: 'required4adddialog', width: storageUtil.getColumnWidthFromStorage('required4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'dataoptions4adddialog', label: 'dataoptions4adddialog', width: storageUtil.getColumnWidthFromStorage('dataoptions4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'style4adddialog', label: 'style4adddialog', width: storageUtil.getColumnWidthFromStorage('style4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'charttype', label: 'charttype', width: storageUtil.getColumnWidthFromStorage('charttype', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnDatatype', label: 'columnDatatype', width: storageUtil.getColumnWidthFromStorage('columnDatatype', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnIsnotnull', label: 'columnIsnotnull', width: storageUtil.getColumnWidthFromStorage('columnIsnotnull', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'queryType', label: 'queryType', width: storageUtil.getColumnWidthFromStorage('queryType', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'defaultValue', label: 'defaultValue', width: storageUtil.getColumnWidthFromStorage('defaultValue', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnTip', label: 'columnTip', width: storageUtil.getColumnWidthFromStorage('columnTip', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'dataTransfer', label: 'dataTransfer', width: storageUtil.getColumnWidthFromStorage('dataTransfer', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'columnlayoutStyle4adddialog', label: 'columnlayoutStyle4adddialog', width: storageUtil.getColumnWidthFromStorage('columnlayoutStyle4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
]

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

export const pickerOptionsSingleDate = {
  disabledDate(time) {
    return time.getTime() > Date.now()
  },
  shortcuts: [{
    text: '今天',
    onClick(picker) {
      picker.$emit('pick', new Date())
    }
  }, {
    text: '昨天',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      picker.$emit('pick', date)
    }
  }, {
    text: '一周前',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', date)
    }
  }]
}
